<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("modelConfigPath", "shop");
%>
<%@ include file="/WEB-INF/views/shared/master/contentHeader.jsp"%>
<style >

</style>
<t:panel cssClass="panel-flat form-detailed" customBody="true" customHead="true">
	<div class="detailed-navbar-content panel-body">
		<t:form modelAttribute="payment" action="/shop/payment/save" method="post" cssClass="form-horizontal">
			<div class="hide">
				 <t:hidden path="paymentId"/>
 				 <t:hidden path="deleteMark"/>	
 				 <t:hidden path="createUserName"/>
		 		 <t:hidden path="createUserId"/>
		 		 <t:hidden path="createDate"/>
		 		 <t:hidden path="shopId"/>
		 		 <t:hidden path="billingId"/>
			</div>
            <t:formgroup>
                <t:label path="customerId" cssClass="col-sm-2 col-xs-2" />
                <t:select2 path="customerId" placeholder="请填写客户" allowClear="true" colClass="col-sm-4 col-xs-4"></t:select2>
                <t:label path="paymentState" cssClass="col-sm-2 col-xs-2" />
				<t:select2 path="paymentState" placeholder="请填写付款类型" allowClear="true" colClass="col-sm-4 col-xs-4"></t:select2>
			</t:formgroup>
            <t:formgroup>
            	<t:label path="amount" cssClass="col-sm-2 col-xs-2" />
				<t:input  onkeyup="return ValidateNumber(this,value)" path="amount" colClass="col-sm-4 col-xs-4" />
				<t:label path="type" cssClass="col-sm-2 col-xs-2" />
				<t:select2 path="type" placeholder="请填写付款方式" allowClear="true" colClass="col-sm-4 col-xs-4"></t:select2>
            </t:formgroup>
            <t:formgroup>   
				<t:label path="comment" cssClass="col-sm-2 col-xs-2" />
				<t:input path="comment" colClass="col-sm-4 col-xs-4" />
            </t:formgroup>
           
		</t:form>
	</div>
	<t:panelFoot headingBtnCssClass="heading-btn pull-right-important">
		<c:if test="${t_type ne 'check' }">
			<t:button icon="icon-floppy-disk" onclick="saveData()" laddaType="progress" cssClass="btn-info" csize="sm">保存</t:button>
		</c:if>
	</t:panelFoot>
</t:panel>

<script type="text/javascript">

$(function(){
	amountChange();

});
function amountChange(){
	$('#amount').bind('input propertychange', function() {
		var price = parseFloat($(this).val());
		$(this).val(price)
		if(isNaN(price)){
			price = 0;
			$(this).val(0);
		}else{
			var unpaidAmount=parseFloat($("#billing_unpaidAmount").val());
			if(price > unpaidAmount){
				$(this).val(unpaidAmount);
			}
		}
		
	});
}

function saveData(lBtn){
	if($('#amount').val()==0){
		$.showTips("请填写付款金额！",1000,"warning");
		return;
	}
	if (!$("form:first").valid()){
		return;
	}
	lBtn.start();
	$("form:first").submit();
}	

function ValidateNumber(e, pnumber){
	if (!/^\d+[.]?\d*$/.test(pnumber))
	{
	e.value = /^\d+[.]?\d*/.exec(e.value);
	}else{
		
 	}
	return false;
}

function actionResultCallBack(){
	var result={close:true,refresh:false};
	var level=$("#level").val();
	if(level=='0'){
		top.main.relevanceIframe.paymentIframe.formSubmit();
	}else if(level=='5'){
		top.customer_form.paymentIframe.formSubmit();
	}else{
		top.main.formSubmit();
	}
	return result;
}

</script>
<%@ include file="/WEB-INF/views/shared/base/scripts/jqueryui.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formtags.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formbuttons.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formpickers.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formselects.jsp"%>
<%@ include file="/WEB-INF/views/shared/base/scripts/limitless/default/formstyling.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/dialog.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/contentFooter.jsp"%>